import java.util.Random;

public class text {
    public static void main(String[] args) {
        Random random=new Random();
        for(int i=0;i<10;i++){
            int it = random.nextInt(10);
            System.out.println(it);
        }

    }
}




class Test {

    public static void main(String[] args) {
        Student s = new Student("李四"){  //匿名子类
            @Override
            void ok() {
                System.out.println("送给AAA吃");
            }
        };
        System.out.println("打游戏");
        s.order("小面", "小四");
        s.game();

        Student s1 = new Student("李小四"){
            @Override
            void ok() {
                System.out.println("你自己吃掉");
            }
        };
        System.out.println("打游戏");
        s1.order("汉堡", "小五");
        s1.game();
    }
}

class OutTake extends Thread {
    String staff;
    String content;
    CallBack callBack;

    OutTake(String staff, String c, CallBack callBack) {
        this.staff = staff;
        this.content = c;
        this.callBack = callBack;
    }

    @Override
    public void run() {
        delvery();
    }

    void delvery() {
        int i = 0;
        while (i < 10) {
            System.out.println(staff + "送" + content + ";" + i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            i = i + 1;
        }
        System.out.println("ok");
        callBack.callBack("ok");
    }

}

interface CallBack {
    void callBack(String r);
}

class Teacher implements CallBack {
    String name;

    Teacher(String n) {
        name = n;
    }

    void order(String content, String staff) {
        OutTake o = new OutTake(staff, content, this);
        o.start();
    }

    void teaching() {
        int i = 0;
        while (i < 15) {
            System.out.println(name + "上课;" + i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            i = i + 1;
        }
    }

    public void callBack(String r) {
        if (r.equals("ok")) {
            System.out.println("放在物联网办公室");
        }
    }
}

abstract class Student implements CallBack {
    String name;

    Student(String n) {
        name = n;
    }

    void order(String content, String staff) {
        OutTake o1 = new OutTake(staff, content, this);
        o1.start();
    }

    void game() {
        int i = 0;
        while (i < 15) {
            System.out.println(name + "打游戏;" + i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            i = i + 1;
        }
    }

    abstract void ok();

    @Override
    public void callBack(String r) {
        if (r.equals("ok")) {
            ok();
        }
    }
}

